﻿Public Class Settings
    Private systemsettings As New My.MySettings

    Private Sub Settings_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        MainMenu.Show()

    End Sub

    Private Sub Settings_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub
    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
        If ComboBox1.SelectedIndex = 0 Then
            ComboBox2.Items.Clear()
            ComboBox2.Items.AddRange(New Object() {"Invoice Form", "Manage Customers", "Manage Employees", "Manage Invoices", "Settings"})
        ElseIf ComboBox1.SelectedIndex = 1 Then
            ComboBox2.Items.Clear()
            ComboBox2.Items.AddRange(New Object() {"New Item1", "New Item 2"})
        ElseIf ComboBox1.SelectedIndex = 2 Then
            ComboBox2.Items.Clear()
            ComboBox2.Items.AddRange(New Object() {"New Item3", "New Item 4"})
        ElseIf ComboBox1.SelectedIndex = 3 Then
            ComboBox2.Items.Clear()
            ComboBox2.Items.AddRange(New Object() {"New Item5", "New Item 6"})
        ElseIf ComboBox1.SelectedIndex = 4 Then
            ComboBox2.Items.Clear()
            ComboBox2.Items.AddRange(New Object() {"New Item7", "New Item 8"})
        ElseIf ComboBox1.SelectedIndex = 5 Then
            ComboBox2.Items.Clear()
            ComboBox2.Items.AddRange(New Object() {"New Item9", "New Item 10"})
        End If
    End Sub

    Private Sub ComboBox2_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox2.SelectedIndexChanged
        TextBox1.Focus()
    End Sub

    Private Sub TextBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
        Label9.Visible = True
        Label9.Text = e.KeyValue.ToString
    End Sub

    Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
        TextBox1.SelectAll()
        If TextBox1.Text = Nothing Then
            Label9.Visible = False
        End If
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If ComboBox1.SelectedIndex = 0 And ComboBox2.SelectedIndex = 0 Then
            systemsettings.MainMenuInvoiceFormShortcut = Label9.Text
            systemsettings.Save()
            MainMenu.Label7.Text = "Keyboard shortcut : " & TextBox1.Text
            MsgBox("Keyboard control has been changed successfully", MsgBoxStyle.Information, "Information")
            ElseIf ComboBox1.SelectedIndex = 0 And ComboBox2.SelectedIndex = 1 Then
            systemsettings.MainMenuManageCustomerShortcut = Label9.Text
                systemsettings.Save()
            MainMenu.Label8.Text = "Keyboard shortcut : " & TextBox1.Text
            MsgBox("Keyboard control has been changed successfully", MsgBoxStyle.Information, "Information")
            ElseIf ComboBox1.SelectedIndex = 0 And ComboBox2.SelectedIndex = 2 Then
            systemsettings.MainMenuManageEmployeeShortcut = Label9.Text
            systemsettings.Save()
            MainMenu.Label9.Text = "Keyboard shortcut : " & TextBox1.Text
            MsgBox("Keyboard control has been changed successfully", MsgBoxStyle.Information, "Information")
            ElseIf ComboBox1.SelectedIndex = 0 And ComboBox2.SelectedIndex = 3 Then
            systemsettings.MainMenuManageInvoiceShortcut = Label9.Text
            systemsettings.Save()
            MainMenu.Label10.Text = "Keyboard shortcut : " & TextBox1.Text
            MsgBox("Keyboard control has been changed successfully", MsgBoxStyle.Information, "Information")
            ElseIf ComboBox1.SelectedIndex = 0 And ComboBox2.SelectedIndex = 4 Then
            systemsettings.MainMenuSettingsShortcut = Label9.Text
            systemsettings.Save()
            MainMenu.Label11.Text = "Keyboard shortcut : " & TextBox1.Text
            MsgBox("Keyboard control has been changed successfully", MsgBoxStyle.Information, "Information")
            End If
    End Sub
End Class